package com.jacky.serial;

import java.io.Serializable;

/**
 * 可序列化的单例模式
 * 反序列化后不再单例
 * 可以自定义readResolve()方法解决
 */
public class SingletonE implements Serializable {
    private SingletonE(){};
    private static SingletonE single = new SingletonE();
    public static SingletonE getInstance(){

        return single;
    }

    private Object readResolve() throws Exception {
        return SingletonE.single;
    }
}
